<!--
 * @Descripttion:
 * @Author: Silence
 * @Date: 2023-05-30 20:34:13
 * @LastEditors: Silence
 * @LastEditTime: 2023-05-30 22:02:48
-->
<template>
  <div>
    <van-nav-bar title="注册" />
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="username"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px">
        <van-button block type="primary" native-type="submit">注册</van-button>
      </div>
    </van-form>
    <div style="text-align: center">
      <router-link class="link" to="/login">有账号，去登录</router-link>
    </div>
  </div>
</template>
<script>
import request from '../utils/request.js'
export default {
  data () {
    return {
      username: '',
      password: ''
    }
  },
  created () {
  },
  computed: {
  },
  methods: {
    async onSubmit (values) {
      const res = await request({
        url: '/user/register',
        method: 'post',
        data: values
      })
      console.log(res)
      this.$toast('res.response.message')
    }
  }
}
</script>
<style lang='less'  scoped>
</style>
